﻿// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'

#warning Upgrade NOTE: unity_Scale shader variable was removed; replaced 'unity_Scale.w' with '1.0'

Shader "Toon/tankPlayerShader3" {
	Properties {
		_MainTex ("Base (RGB)", 2D) = "white" {}
		_BumpMap ("Normal map (RGB)", 2D) = "white" {}
		_Ramp ("Toon Ramp (RGB)", 2D) = "gray" {}

		//SPECULAR
		_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
		_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
		
		//COLORS
		_Color ("Highlight Color", Color) = (0.8,0.8,0.8,1)
		_SColor ("Shadow Color", Color) = (0.0,0.0,0.0,1)
		
		//OUTLINE
		_Outline ("Outline Width", Range(0,0.05)) = 0.005
		_OutlineColor ("Outline Color", Color) = (0.2, 0.2, 0.2, 1)
	}
	SubShader {
		Tags { 
			"Queue"="Geometry+5" 
			"IgnoreProjector"="True"
		 }
		LOD 200

		Pass {
			Name "BASE"
			
			LOD 200
			CGPROGRAM

			#pragma vertex vert 
	        #pragma fragment frag
	        #include "UnityCG.cginc"

			struct VertIn {
	        	float4 vertex : POSITION;
	        	float4 texcoord : TEXCOORD0;
				float4 tangent : TANGENT;
				float3 normal : NORMAL;
	        };

		    struct v2f {
	        	float4 pos : SV_POSITION;
	        	float2 uv : TEXCOORD0;

				fixed3 I : TEXCOORD3;
				fixed3 TtoW0 : TEXCOORD4;
				fixed3 TtoW1 : TEXCOORD5;
				fixed3 TtoW2 : TEXCOORD6;

			};

			sampler2D _MainTex;
			sampler2D _BumpMap;
			sampler2D _Ramp;

			uniform fixed4 _Color;
			uniform fixed4 _SColor;
			 

			v2f vert(VertIn v) 
			{
				v2f o;
				o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
				o.uv = v.texcoord.xy;

				o.I = -WorldSpaceViewDir(v.vertex);
				TANGENT_SPACE_ROTATION;
				o.TtoW0 = mul(rotation, unity_ObjectToWorld[0].xyz*1.0);
				o.TtoW1 = mul(rotation, unity_ObjectToWorld[1].xyz*1.0);
				o.TtoW2 = mul(rotation, unity_ObjectToWorld[2].xyz*1.0);
				return o;
			}

			fixed4 frag(v2f i) : Color {
			/*
				fixed3 lightDir = normalize(fixed3(1, 1, 1));
				fixed3 normal = UnpackNormal(tex2D(_BumpMap, i.uv));
				fixed3 wn;
				wn.x = dot(i.TtoW0, normal); 
				wn.y = dot(i.TtoW1, normal); 
				wn.z = dot(i.TtoW2, normal); 


				fixed ndl = dot(lightDir, wn)*0.5+0.5;
				fixed3 ramp = tex2D(_Ramp, fixed2(ndl, ndl));
				ramp = lerp(_SColor, _Color, ramp);

				col.rgb = col.rgb * (ramp);
				*/

				fixed4 col = tex2D(_MainTex, i.uv);
				return col;
			}

			ENDCG
		}
		
	} 
	FallBack "Diffuse"
}
